import request from '@/config/axios'
import type { Dayjs } from 'dayjs';

/** 部门协同-工作任务信息 */
export interface WorkTask {
    id: number; // ID
    taskName?: string; // 任务名称
    parentId: number; // 父id
    finishState: string; // 完成状态
    creatorDept: number; // 发起人部门
    executeUser: string; // 执行人
    deadline: string | Dayjs; // 截止时间
    content: string; // 任务内容
    priority: string; // 优先级
    label: string; // 标签
    taskFile: string; // 关联文件
    remark: string; // 备注
    assistUser: string; // 协助人
}

// 部门协同-工作任务 API
export const WorkTaskApi = {
    // 查询部门协同-工作任务分页
    getWorkTaskPage: async (params: any) => {
        return await request.get({ url: `/synergy/work-task/page`, params })
    },

    // 查询部门协同-工作任务详情
    getWorkTask: async (id: number) => {
        return await request.get({ url: `/synergy/work-task/get?id=` + id })
    },

    // 新增部门协同-工作任务
    createWorkTask: async (data: WorkTask) => {
        return await request.post({ url: `/synergy/work-task/create`, data })
    },

    // 修改部门协同-工作任务
    updateWorkTask: async (data: WorkTask) => {
        return await request.put({ url: `/synergy/work-task/update`, data })
    },

    //完成执行任务
    finishExecuteTask: async (data: any) => {
        return await request.put({ url: `/synergy/work-task/finishExecuteTask`, data })
    },
    //新增执行任务
    addExecuteTask: async (data: any) => {
        return await request.post({ url: `/synergy/work-task/addExecuteTask`, data })
    },

    // 删除部门协同-工作任务
    deleteWorkTask: async (id: number) => {
        return await request.delete({ url: `/synergy/work-task/delete?id=` + id })
    },

    /** 批量删除部门协同-工作任务 */
    deleteWorkTaskList: async (ids: number[]) => {
        return await request.delete({ url: `/synergy/work-task/delete-list?ids=${ids.join(',')}` })
    },

    // 导出部门协同-工作任务 Excel
    exportWorkTask: async (params) => {
        return await request.download({ url: `/synergy/work-task/export-excel`, params })
    }
}
